<?php

namespace app\api\validate;

use think\Validate;

class PageSetting extends Validate
{
    protected $rule = [
        'id'            => 'require',
        'agent_id'      => 'require',
        'setting_name'  => 'require|max:100',
        'image'         => 'require',
        'sort '         => 'require',
        'status '       => 'require|in:-1,1',
        'type '         => 'require|in:1,2,3',
        'sub_category'  => 'require',
        'jump_type'     => 'require',
        'path'          => 'require',
        'source'        => 'require|in:1,2',
        'position'      => 'require|in:1,2',
    ];

    protected $message = [
        'id.require'            =>  'id 不能为空',
        'setting_name.require'  =>  '请输入名称',
        'setting_name.max'      =>  '名称不能超过 32 个字符',
        'image.require'         =>  '请上传图片',
        'jump_type.require'     =>  '请选择跳转类型',
        'jump_type.in'          =>  '跳转类型有误',
        'path'                  =>  '请输入H5链接地址',
        'type.require'          =>  '类型不能为空',
        'type.in'               =>  '类型有误',
        'sub_category.require'  =>  '子类型不能为空',
        'status.require'        =>  '状态不能为空',
        'status.in'             =>  '状态有误',
        'source.require'        =>  '来源不能为空',
        'source.in'             =>  '来源有误',
        'position.require'      =>  '轮播图位置不能为空',
        'position.in'           =>  '轮播图位置有误',
    ];

    protected $scene = [
        //列表查询
        'list' => [
            'type',
            'sub_category',
        ],
        //新增
        'create' => [
            'setting_name',
            'type',
            'sub_category',
            'image',
            'jump_type',
            'sort',
            'path',
        ],
        //修改
        'update' => [
            'id',
            'type',
            'sub_category',
            'setting_name',
            'image',
            'jump_type',
        ],
        //删除
        'delete' =>[
            'id',
        ],
        //修改状态
        'status' =>[
            'id',
            'status',
        ],
        //同步
        'sync' =>[
            'type',
            'sub_category',
        ]
    ];
}
